﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.DBM;
using KPIS.GERP.GBMS.MODEL;
using System.Globalization;

namespace KPIS.GERP.GBMS.BLL
{
    public class ProjectOperation
    {
        DBManager dbManager = new DBManager(SystemInfo._DataProvider, SystemInfo._ConnectionString);

        public int CountProjectOperation(string strBgmProjSeq)
        {
            int intCount = 0;

            try
            {
                dbManager.CreateParameters(2);
                dbManager.AddParameters(0, "@record_status", SystemInfo._ApproveRecordStatus);
                dbManager.AddParameters(1, "@bgm_proj_seq", strBgmProjSeq);

                string sql;
                sql = " select count(*) as proj_oper_count"
                    + " from bgm_project_operation p"
                    + " where p.record_status = @record_status"
                    + " and bgm_proj_seq = @bgm_proj_seq";
                dbManager.Open();
                DataTable dtb = dbManager.ExecuteDataSet(CommandType.Text, sql).Tables[0];

                if (dtb.Rows.Count > 0)
                {
                    intCount = Convert.ToInt32(dtb.Rows[0][0]);
                }

                return intCount;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dbManager.Dispose();
            }
        }
    }
}
